package com.hos.punchtheclocksystem.controller;


import com.hos.punchtheclocksystem.pojo.Patient;
import com.hos.punchtheclocksystem.pojo.PostCard;
import com.hos.punchtheclocksystem.service.PatientService;
import com.hos.punchtheclocksystem.service.PostCardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;


@Controller
public class IndexController {

    @Autowired
    PatientService patientService;

    @Autowired
    PostCardService postCardService;

    @GetMapping("/cardEdit/{id}")
    public String cardEdit(@PathVariable Integer id, Model model){
        PostCard postCard = postCardService.get(id);
        model.addAttribute("card",postCard);

        return "cardEdit";
    }

    @GetMapping("/patientEdit/{id}")
    public String patientEdit(@PathVariable Integer id, Model model){
        Patient patient = patientService.get(id);
        model.addAttribute("patient",patient);
        return "patientEdit";
    }

}
